import pandas as pd, numpy as np
import config
class Reader():
    def __init__(self, filename):
        self.filename = filename
        self.T = pd.read_excel(filename, sheet_name=1, usecols="F:P", header=None, skiprows=2, nrows=1, engine='openpyxl').to_numpy()[0]
        P_GDP_df = pd.read_excel(filename, sheet_name=1, usecols="F:P", header=None, skiprows=3, nrows=9, engine='openpyxl').to_numpy()
        self.P_GDP = pd.DataFrame(P_GDP_df.T, columns=['P', 'GDP_t', 'GDP_1_1', 'GDP_2_t', 'GDP_2_1', 'GDP_2_2', 'GDP_3_t', 'GDP_3_1', 'GDP_3_2'])
        Energy_df = pd.read_excel(filename, sheet_name=1, usecols="F:P", header=None, skiprows=37, nrows=85-37, engine='openpyxl').to_numpy()
        self.Energy = pd.DataFrame(Energy_df.T[:,np.array([*np.arange(0,6), *np.arange(12,24), *np.arange(30,48)])], columns=[i+'.'+j for i in config.industryName for j in config.energyName])
        Carbon_df = pd.read_excel(filename, sheet_name=2, usecols="F:P", header=None, skiprows=2, nrows=6, engine='openpyxl').to_numpy()
        self.Carbon = pd.DataFrame(Carbon_df.T[:,np.array([0,1,3,4,5])], columns=config.industryName[np.array([0,2,3,4,5])])
        Carbon_Energy_df = pd.read_excel(filename, sheet_name=3, usecols="F:P", header=None, skiprows=15, nrows=45-15, engine='openpyxl').to_numpy()
        self.Carbon_Energy = pd.DataFrame(Carbon_Energy_df.T, columns=[i+'.'+j for i in config.industryName[np.array([0,2,3,4,5])] for j in config.energyName])
